/**   
 * Copyright © 2016 北京之洲科技有限责任公司. All rights reserved.
 * 
 * @Title: KBReflectFileOfAutoHome.java 
 * @Prject: carfactory
 * @Package: com.zizo.reflect.autohome.kb 
 * @Description: 
 * @author: Alexis  
 * @email heyan0227@outlook.com
 * @date: 2016年8月2日 下午2:23:16 
 * @version: V1.0   
 */
package com.zizo.reflect.autohome.price;

import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import com.zizo.core.ReflectFile;
import com.zizo.util.DocUtil;
import com.zizo.util.Util;

/**
 * @ClassName: KBReflectFileOfAutoHome
 * @Description:
 * @author: Alexis
 * @date: 2016年8月2日 下午2:23:16
 */
public class PriceReflectFileOfAutoHome extends ReflectFile {
	/**
	 * @Title:PriceReflectFileOfAutoHome
	 * @Description:
	 * @param id
	 */
	public PriceReflectFileOfAutoHome(String id) {
		super(id);
		// TODO Auto-generated constructor stub
	}

	public void getItems(String url) {
		System.out.println(url);
		Document doc = DocUtil.getDoc(url);
		Elements lis = doc.select("li.price-item");
		Util.downloadWebsite("D:/var/server/reflectfile/autohome/price/" + this.id, this.id + ".html", url);
		for (Element li : lis) {
			String link = li.select("li.head-item div.txcon a").attr("href");
			String price_id = li.attr("data-pkid");
			Util.downloadWebsite("D:/var/server/reflectfile/autohome/price/" + this.id + "/next", price_id + ".html",
					link);
		}
	}

	/*
	 * (non Javadoc)
	 * 
	 * @Title: run
	 * 
	 * @Description:
	 * 
	 * @see com.zizo.core.ReflectFile#run()
	 */
	@Override
	public void run() {
		getItems("http://jiage.autohome.com.cn/list-0-0-0-0-0-" + this.id);
	}

	public static void main(String[] args) {
		PriceReflectFileOfAutoHome price = new PriceReflectFileOfAutoHome(1 + "");
		price.run();
	}
}
